package com.wanmait.recruit.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recruit.mapper.PositionTypeMapper;
import com.wanmait.recruit.pojo.Position;
import com.wanmait.recruit.pojo.PositionType;
import com.wanmait.recruit.pojo.School;
import com.wanmait.recruit.service.PositionTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service("positionTypeService")
public class PositionTypeServiceImp implements PositionTypeService {
    @Resource
    private PositionTypeMapper positionTypeMapper;
    @Override
    public PageInfo<PositionType> findAll(String typeName, Integer pageNum,Integer typeId) {
        int pageSize = 10;
        PageHelper.startPage(pageNum,pageSize);
        List<PositionType> positionTypes = positionTypeMapper.findAllByPositionTypeName(typeName,typeId);
        PageInfo<PositionType> pageInfo = new PageInfo<>(positionTypes,11);
        return pageInfo;
    }

    @Override
    public Boolean isRename(String typeName) {
        PositionType positionType = positionTypeMapper.findByName(typeName);
        if(positionType==null){
            return true;
        }
        else {
            return false;
        }
    }

    @Override
    public void deleteById(Integer id) {
        positionTypeMapper.deleteById(id);
    }

    @Override
    public List<PositionType> findAll() {
        return positionTypeMapper.findAll();
    }

    @Override
    public String selectByPositionTypeId(Integer positionTypeId) {
        PositionType positionType = positionTypeMapper.selectByPrimaryKey(positionTypeId);
        return positionType.getPositionTypeName();
    }

    @Override
    public ArrayList<PositionType> selectFindAll() {
        return positionTypeMapper.findAll2();
    }

    @Override
    public List<PositionType> selectFindAllAndPosition() {
        return positionTypeMapper.findAllAndPositions();
    }

    @Override
    public List<PositionType> findAllByIndustryId(Integer industryId) {
        return positionTypeMapper.findAllByIndustryId(industryId);
    }

    @Override
    public void insert(PositionType object) {
        positionTypeMapper.insert(object);
    }

    @Override
    public void delete(PositionType object) {

    }

    @Override
    public void update(PositionType object) {

    }

    @Override
    public PageInfo<PositionType> search(int pageNum, int pageSize) {
        return null;
    }
}
